// 引入request模块
import request from '@/utils/request'

// 按条件分页查询资源接口
export const getResourcePages = data => {
  return request({
    method: 'POST',
    url: '/boss/resource/getResourcePages',
    data
  })
}
// 查询资源分类接口
export const getResourcecategories = params => {
  return request({
    method: 'GET',
    url: '/boss/resource/category/getAll',
    params
  })
}
// 保存或者更新资源 /boss/resource/saveOrUpdate
export const saveOrUpdateResource = data => {
  return request({
    method: 'POST',
    url: '/boss/resource/saveOrUpdate',
    data
  })
}
// 删除资源
export const deleteResource = id => {
  return request({
    method: 'DELETE',
    url: `/boss/resource/${id}`
  })
}
// 获取资源 /boss/resource/{id}
export const getResourceById = id => {
  return request({
    method: 'GET',
    url: `/boss/resource/${id}`
  })
}
// 删除资源分类，如果资源分类下有资源，不允许删除 /boss/resource/category/{id}
export const deleteResourceCategory = id => {
  return request({
    method: 'DELETE',
    url: `/boss/resource/category/${id}`
  })
}
// 保存或更新资源分类 /boss/resource/category/saveOrderUpdate
export const saveOrderUpdate = data => {
  return request({
    method: 'POST',
    url: '/boss/resource/category/saveOrderUpdate',
    data
  })
}
// 获取所有资源
export const getAllResources = () => {
  return request({
    method: 'GET',
    url: '/boss/resource/getAll'
  })
}
// 给角色分配资源 /boss/resource/allocateRoleResources
export const allocateRoleResources = data => {
  return request({
    method: 'POST',
    url: '/boss/resource/allocateRoleResources',
    data
  })
}
// 获取角色拥有的资源信息
export const getRoleResources = roleId => {
  return request({
    method: 'GET',
    url: '/boss/resource/getRoleResources',
    params: {
      roleId
    }
  })
}
